package br.com.sistema.models;

import java.util.Calendar;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;

@Entity
@Table(name="entidade_tipo")
public class EntidadeTipo {

	@Id
	@Column(name="entitipoid")
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int entitipoid;
	
	@Column(name="entitiponome", length=50, nullable=false)
	private String entitiponome;

	@Column(name="xdatai", nullable=false)
	@Temporal(TemporalType.TIMESTAMP)
	private Calendar xdatai;
	
	@Column(name="xdatau", nullable=false)
	@Temporal(TemporalType.TIMESTAMP)
	private Calendar xdatau;
	
	@Column(name="xusuario", nullable=false)
	private String xusuario;

	@Version
	@Column(name="xversao")
	private Integer xversao;
	
	@PrePersist
	public void prePersist(){
		xdatai = Calendar.getInstance();
		xdatau = Calendar.getInstance();
	}
	
	@PreUpdate
	public void preUpdate(){
		xdatau = Calendar.getInstance();
	}
	
	public int getEntitipoid() {
		return entitipoid;
	}

	public void setEntitipoid(int entitipoid) {
		this.entitipoid = entitipoid;
	}

	public String getEntitiponome() {
		return entitiponome;
	}

	public void setEntitiponome(String entitiponome) {
		this.entitiponome = entitiponome;
	}

	public Calendar getXdatai() {
		return xdatai;
	}

	public void setXdatai(Calendar xdatai) {
		this.xdatai = xdatai;
	}

	public Calendar getXdatau() {
		return xdatau;
	}

	public void setXdatau(Calendar xdatau) {
		this.xdatau = xdatau;
	}

	public String getXusuario() {
		return xusuario;
	}

	public void setXusuario(String xusuario) {
		this.xusuario = xusuario;
	}
	
}
